package com.mycat.chat.two.socket.server;

import com.mycat.chat.two.handle.base.Context;
import com.mycat.chat.two.handle.base.MessageHandle;
import com.mycat.chat.two.handle.base.MessageHandleInstance;

import java.io.IOException;
import java.nio.channels.SelectionKey;

/**
 * 聊天服务服务端
 *
 * @author roger.
 * @email 190642964@qq.com
 * @create 2017-02-24
 */
public class ChatServer extends ChatNIOServer {

    public ChatServer() {
        super();
    }

    @Override
    public void receiveMsg(SelectionKey key,String message) {
        System.out.println("服务端收到客户端发出的消息: " + message);

        MessageHandle messageHandle = MessageHandleInstance.newInstance(message);
        Context context = new Context(messageHandle);
        context.actionHandle();

    }

    @Override
    public void sendMsg() {

    }

    public static void main(String[] args) throws IOException {
        new ChatServer().listener();
    }
}
